#pragma once
#include "../Geometry.h"
#include "../../source/IGraphics.h"


#define MAX_PARTICLES 500
#define MAX_TYPES 5

class Emitter
{
private:

	struct Type
	{
		int m_nNumSpawn;
		float m_fAccel;
		float m_fRemainingLifetime;
		HTexture m_hTexture;
		SPoint m_fDirVec;
		SPoint m_fStartPos;
	};

	struct Particle
	{
		float m_fAccel;
		float m_fRemainingLifetime;
		SPoint m_fPos;
		SPoint m_fDir;
		HTexture m_hTexture;
		void InitParticle(Emitter* mEmit, unsigned int nType, int nIndex);
	};

	Type m_Types[MAX_TYPES];
	Particle m_Particles[MAX_PARTICLES];
	const char* nextParticle;
	bool m_bAlive;
	int m_nCurActive;
	int m_nTotalActive;
	int m_nTotalActiveTypes;

public:

	Emitter(void);
	~Emitter(void);

	void AllocateParticles(unsigned int typeIndex, int num);
	void Init(const char* ParticleFile);
	void Destroy(void);
	void Update(float fElapsedTime);
	void Render(void);
	bool isAlive(void) { return m_bAlive; }
};

